/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ialsynth2012;

import java.sql.*;

/**
 *
 * @author Jonas
 */

public class DBConnector {
    private float attack, decay, release, sustain;
    private int waveform;
    public void connect(){
        try{
            
            Class.forName("com.mysql.jdbc.Driver").newInstance();
            String URL = "jdbc:mysql://127.0.0.1:3306/preset_database?user=root&password=ljuddesign";
            Connection connection = DriverManager.getConnection(URL);
            getPreset(connection);
            
        }
        catch(Exception error){
            System.err.println("ERROR: " + error); 
        }  
    }
    public void getPreset(Connection connection){
        try{
        Statement statement = connection.createStatement();
        ResultSet result = statement.executeQuery("SELECT * FROM Presets");
        while(result.next()){
            int waveform = result.getInt("waveform");
            float attack = result.getFloat("attack_value");
            float decay  = result.getFloat("decay_value");
            float sustain = result.getFloat("sustain_value");
            float release = result.getFloat("release_value");
            System.out.println("Attack: " + attack + "\n" +
                    "Decay: " + decay + "\n" +
                    "Sustain: " + sustain + "\n" +
                    "Release: " + release);
        }
        }
        catch(Exception error){
            System.err.println("ERROR: " +error);
        }
    }
}
